<?php


class Daohang extends ORM_Table {
    static protected $table_name = 'daohang';
    
    static public function getTableName($params = null) {
        //$table_name = self::$table_name.substr($params['article_type_id'], 0, 1);
        return self::$table_name;
    }
    
    public function getTagsArr() {
        if (!empty($this->field['tags'])) {
            $tags = explode(' ', $this->field['tags']);
        } else {
            $tags = array();
        }
        return $tags;
    }
    
    public function getComments() {
        $comments = ORM_Finder::find('Comment', array('article_id' => $this->getId()), '*', 'created_at DESC');
        return $comments;
    }
    
    static public function getArticleById($id) {
        if (!empty($id)) {
            $articles = ORM_Finder::find('Article', 'id IN ('.join(',', $id).')', '*', 'created_at DESC');
        } else {
            $articles = array();
        }
        return $articles;
    }
}

